#include "Game.hpp"
#include "Player.hpp"

#include "TurnSchedule.hpp" 

unsigned int TurnSchedule::Ticks;
std::map<unsigned int, std::vector<ITurnTaker*> > TurnSchedule::Schedule;

void TurnSchedule::clear()
{
	Schedule.clear();
}

void TurnSchedule::run()
{
	for (unsigned int i = 0; i < Schedule[Ticks].size(); ++i)
		if(!Schedule[Ticks][i]->takeTurn())
		{
			Game::quit();
			break;
		}

	Game::render(gPlayer->getShape(), gPlayer->getPosition(), gPlayer->getSight());

	Schedule[Ticks].clear();
	Ticks++;
}

void TurnSchedule::scheduleTurn(ITurnTaker* obj, unsigned int ticks)
{
	Schedule[Ticks+ticks].push_back(obj);
}
